package com.xdclass.mysql.controller;

import com.xdclass.mysql.constant.RestItemResult;
import com.xdclass.mysql.domain.User;
import com.xdclass.mysql.model.Product;
import com.xdclass.mysql.persist.mapper.generated.ProductMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author daniel
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductMapper productMapper;


    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public String add() {
        for (int i=140000;i<150000;i++){
            Product product = new Product();
            product.setProductSeq("productSeq" + i);
            product.setCreateTime(LocalDateTime.now());
            product.setId((long) i);
            product.setSkuId("skuId" + i);
            product.setSpuId("spuId" + i);
            product.setSaleId("saleId" + i);
            product.setStoreId((long) i);
            product.setUpdateTime(LocalDateTime.now());
            productMapper.insertSelective(product);
        }
        return "success";
    }


    @RequestMapping(value = "/locate/{id}", method = RequestMethod.GET)
    public RestItemResult<User> locate(@PathVariable Long id) {
        RestItemResult<User> result = new RestItemResult<>();
        return result;
    }


}
